#pragma once
#include "DXAMLCommon.h"


#include "XamlWriter.h"

#include "ObjectWriterContext.h"
#include "XamlOptimizedNodeList.h"


class DeferringWriter :
	public XamlWriter
{

private: 
	enum DeferringMode m_eMode;
	XBOOL m_fHandled;
	xshared_ptr<XamlOptimizedNodeList> m_spDeferredList;
	xshared_ptr<XamlWriter> m_spDeferredWriter;
	xshared_ptr<XamlProperty> m_spDeferredProperty;
	XINT32 m_iDeferredTreeDepth;
	xshared_ptr<ObjectWriterContext> m_spContext;
public: 
	DeferringWriter(xshared_ptr<ObjectWriterContext> & spContext);
	virtual ~DeferringWriter();
	XBOOL get_Handled();
	enum DeferringMode get_Mode();
	HRESULT CollectTemplateList(xshared_ptr<XamlOptimizedNodeList> & spXamlNodeList);
	HRESULT CollectDeferredProperty(xshared_ptr<XamlOptimizedNodeList> &, xshared_ptr<XamlProperty> &);
	virtual HRESULT WriteObject(const xshared_ptr<XamlType> & spXamlType, XBOOL fFromMember);
	virtual HRESULT WriteEndObject();
	virtual HRESULT WriteMember(const xshared_ptr<XamlProperty> & spProperty);
	virtual HRESULT WriteEndMember();
	virtual HRESULT WriteValue(const xshared_ptr<XamlQualifiedObject> & spValue);
	virtual HRESULT WriteNamespace(const xshared_ptr<CXString> & spPrefix, const xshared_ptr<XamlNamespace> & spXamlNamespace);
	virtual HRESULT GetSchemaContext(xshared_ptr<XamlSchemaContext> & spXamlSchemaContext) const;
};



